﻿using Microsoft.AspNetCore.Authentication;
using System;

namespace Surbowl.AspNetCore.Authentication.GitHubBearer
{
    public static class JwtBearerExtensions
    {
        public static AuthenticationBuilder AddGitHubBearer(this AuthenticationBuilder builder)
        {
            return builder.AddGitHubBearer(GitHubBearerDefaults.AuthenticationScheme, delegate { });
        }

        public static AuthenticationBuilder AddGitHubBearer(this AuthenticationBuilder builder, Action<GitHubBearerOptions> configureOptions)
        {
            return builder.AddGitHubBearer(GitHubBearerDefaults.AuthenticationScheme, configureOptions);
        }

        public static AuthenticationBuilder AddGitHubBearer(this AuthenticationBuilder builder, string authenticationScheme, Action<GitHubBearerOptions> configureOptions)
        {
            return builder.AddGitHubBearer(authenticationScheme, null, configureOptions);
        }

        public static AuthenticationBuilder AddGitHubBearer(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action<GitHubBearerOptions> configureOptions)
        {
            return builder.AddScheme<GitHubBearerOptions, GitHubBearerHandler>(authenticationScheme, displayName, configureOptions);
        }
    }
}
